package com.telkomsigma.spring.hibernate.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.telkomsigma.spring.hibernate.common.PaginatedResult;
import com.telkomsigma.spring.hibernate.persistence.dao.TeamDaoImpl;
import com.telkomsigma.spring.hibernate.persistence.domain.FootballTeam;


@Service("serviceTeam")
public class TeamServiceImpl implements TeamService {

	@Autowired
	TeamDaoImpl dao;

	/**
	 * @author viper
	 * @param dao
	 *            the dao to set
	 */
	public void setDao(TeamDaoImpl dao) {
		this.dao = dao;
	}

	
	@Transactional(readOnly = false)
	public FootballTeam insert(FootballTeam transientInstance) {
		return dao.insert(transientInstance);
	}

	
	@Transactional(readOnly = false)
	public FootballTeam update(FootballTeam detachedInstance) {
		return dao.update(detachedInstance);
	}

	
	@Transactional(readOnly = false)
	public Boolean remove(FootballTeam persistentInstance) {
		return dao.remove(persistentInstance);
	}

	
	@Transactional(readOnly = false)
	public Boolean removeList(List<FootballTeam> list) {
		return dao.removeList(list);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public FootballTeam findById(Integer id) {
		return dao.findById(id);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public List<FootballTeam> findByProperty(String propertyName, Object value,
			int... rowStartIdxAndCount) {
		return dao.findByProperty(propertyName, value, rowStartIdxAndCount);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public List<FootballTeam> findAll(int... rowStartIdxAndCount) {
		return dao.findAll(rowStartIdxAndCount);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public List<FootballTeam> findLikeProperty(String propertyName, Object value,
			int... rowStartIdxAndCount) {
		return dao.findLikeProperty(propertyName, value, rowStartIdxAndCount);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public List<FootballTeam> findLikeMapOfProperties(
			Map<String, Object> propertiesMap, int... rowStartIdxAndCount) {
		return dao.findLikeMapOfProperties(propertiesMap, rowStartIdxAndCount);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public List<FootballTeam> findByMapOfProperties(
			Map<String, Object> propertiesMap, int... rowStartIdxAndCount) {
		return dao.findByMapOfProperties(propertiesMap, rowStartIdxAndCount);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public Integer countAll() {
		return dao.countAll();
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public Integer countLikeProperty(String propertyName, Object value) {
		return dao.countLikeProperty(propertyName, value);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public Integer countByProperty(String propertyName, Object value) {
		return dao.countByProperty(propertyName, value);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public Integer countLikeMapOfProperties(Map<String, Object> propertiesMap) {
		return dao.countLikeMapOfProperties(propertiesMap);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public Integer countByMapOfProperties(Map<String, Object> propertiesMap) {
		return dao.countByMapOfProperties(propertiesMap);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public PaginatedResult<FootballTeam> paginateLikeMapOfProperties(
			Map<String, Object> propertiesMap, int... rowStartIdxAndCount) {
		return dao.paginateLikeMapOfProperties(propertiesMap,
				rowStartIdxAndCount);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public PaginatedResult<FootballTeam> paginateAll(int... rowStartIdxAndCount) {
		return dao.paginateAll(rowStartIdxAndCount);
	}

	
	@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
	public PaginatedResult<FootballTeam> paginateByMapOfProperties(
			Map<String, Object> propertiesMap, int... rowStartIdxAndCount) {
		return dao
				.paginateByMapOfProperties(propertiesMap, rowStartIdxAndCount);
	}

}
